<html>
<head><meta charset="utf-8"><title>inline consts typeck · project-const-generics · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/index.html">project-const-generics</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html">inline consts typeck</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="238275645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238275645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238275645">(May 11 2021 at 09:12)</a>:</h4>
<p>I would like to get inline consts to be typechecked together with their parent body in the near future.</p>
<p>Either by implementing this myself or, preferably, by mentoring someone else <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span></p>



<a name="238275686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238275686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238275686">(May 11 2021 at 09:13)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> are you still interested in working on this?</p>



<a name="238307241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238307241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238307241">(May 11 2021 at 13:31)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> <span aria-label="wave" class="emoji emoji-1f44b" role="img" title="wave">:wave:</span>, yes I am</p>



<a name="238307296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238307296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238307296">(May 11 2021 at 13:31)</a>:</h4>
<p>I was a bit absent for the last 2/3 weeks but I'm back to work on rustc, so <span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="238307517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238307517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238307517">(May 11 2021 at 13:33)</a>:</h4>
<p>can you explain a bit what's the current status of things, what do we need to accomplish and ideas on how to accomplish it?</p>



<a name="238317321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238317321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238317321">(May 11 2021 at 14:30)</a>:</h4>
<p>the current status is still your original implementation, in which we typecheck inline consts separately with an inference variable as the expected return type and use the resulting type when typechecking their containing body</p>



<a name="238317826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238317826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238317826">(May 11 2021 at 14:34)</a>:</h4>
<p>what i want you to accomplish is getting the following to compile</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span>: <span class="kt">u32</span> <span class="o">=</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="mi">3</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="238318106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238318106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238318106">(May 11 2021 at 14:35)</a>:</h4>
<p>the way to do it is to typeck inline consts together with their parent body by mostly copying what we're doing for closures (i expect)</p>



<a name="238318357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238318357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238318357">(May 11 2021 at 14:36)</a>:</h4>
<p>i haven't looked at the code too deeply so I can't tell you exactly what needs to be done, if you want we can take an hour to talk about this in sync</p>



<a name="238318614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238318614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238318614">(May 11 2021 at 14:38)</a>:</h4>
<p>if you have a rough idea where to start and want to figure this out on your own that's also fine for me, but no matter what you do, feel free to ask whenever you don't know exactly what to do ^^</p>



<a name="238319108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238319108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238319108">(May 11 2021 at 14:41)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> <span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span>, let me see because I'm also doing other things but will definitely ask or sync with you</p>



<a name="238319150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238319150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238319150">(May 11 2021 at 14:41)</a>:</h4>
<p>btw, how urgent is this? or when are you expecting to have a working version of it?</p>



<a name="238319181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238319181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238319181">(May 11 2021 at 14:41)</a>:</h4>
<p>like most things in rust</p>



<a name="238319200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238319200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238319200">(May 11 2021 at 14:41)</a>:</h4>
<p>it would be good to get it done <em>soon</em></p>



<a name="238319220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238319220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238319220">(May 11 2021 at 14:41)</a>:</h4>
<p>but there is no time limit here</p>



<a name="238319452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238319452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238319452">(May 11 2021 at 14:43)</a>:</h4>
<p><span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span> if you think that you don't have any time to work on it during the next 30 days it might make sense to let someone else do it</p>



<a name="238319469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238319469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238319469">(May 11 2021 at 14:43)</a>:</h4>
<p>apart from that take your time ^^</p>



<a name="238326238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238326238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238326238">(May 11 2021 at 15:22)</a>:</h4>
<p>yeah, I think I can do it</p>



<a name="238685858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238685858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238685858">(May 13 2021 at 21:45)</a>:</h4>
<p>ah I'd be interested in this</p>



<a name="238685881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/238685881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#238685881">(May 13 2021 at 21:45)</a>:</h4>
<p>I also still want to understasnd the need for that defid-hack and not need it :)</p>



<a name="239190448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/239190448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#239190448">(May 18 2021 at 02:47)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/260443-project-const-generics/topic/inline.20consts.20typeck/near/238685881">said</a>:</p>
<blockquote>
<p>I also still want to understasnd the need for that defid-hack and not need it :)</p>
</blockquote>
<p>which defid-hack?</p>



<a name="239222646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/239222646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#239222646">(May 18 2021 at 09:20)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.WithOptConstParam.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.WithOptConstParam.html</a></p>



<a name="246884926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246884926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246884926">(Jul 22 2021 at 18:10)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="116266">@Santiago Pastorino</span></p>



<a name="246884948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246884948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246884948">(Jul 22 2021 at 18:10)</a>:</h4>
<p><span aria-label="wave" class="emoji emoji-1f44b" role="img" title="wave">:wave:</span></p>



<a name="246884958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246884958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246884958">(Jul 22 2021 at 18:10)</a>:</h4>
<p>OK. so</p>



<a name="246884972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246884972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246884972">(Jul 22 2021 at 18:10)</a>:</h4>
<p>let me skim this thread a bit</p>



<a name="246885006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246885006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246885006">(Jul 22 2021 at 18:11)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="246885049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246885049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246885049">(Jul 22 2021 at 18:11)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/260443-project-const-generics/topic/inline.20consts.20typeck/near/238317321">said</a>:</p>
<blockquote>
<p>the current status is still your original implementation, in which we typecheck inline consts separately with an inference variable as the expected return type and use the resulting type when typechecking their containing body</p>
</blockquote>
<p>where does this happen in the code?</p>



<a name="246885068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246885068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246885068">(Jul 22 2021 at 18:11)</a>:</h4>
<p>we have also this information that was the write up for the inline consts being one of the blockers of const generics ...</p>



<a name="246885075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246885075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246885075">(Jul 22 2021 at 18:11)</a>:</h4>
<div class="codehilite"><pre><span></span><code>## inline consts

Current state:

fn test() -&gt; usize {
    const { 3 }
}

The above breaks because `3` is type-checked in its own context, its type defaults to `i32`, and we get compilation errors.

**Proposal:** Inline consts getting typechecked together with their parent is really desirable.

trait Foo {}
fn foo&lt;T: Foo&gt;(_: T) {}
impl Foo for u32 {}
impl Foo for () {}
foo(const { 3 });

Inline consts should also be able to depend on generic parameters and participate in `ConstEvaluatable` checking.

This however requires the mir of inline consts. The idea is therefore to typeck them in a similar fashion to closures. Then after typeck we check their evaluatability in a separate query.

That seems surprisingly straightforward :O
</code></pre></div>



<a name="246885208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246885208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246885208">(Jul 22 2021 at 18:12)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/260443-project-const-generics/topic/inline.20consts.20typeck/near/246885049">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/260443-project-const-generics/topic/inline.20consts.20typeck/near/238317321">said</a>:</p>
<blockquote>
<p>the current status is still your original implementation, in which we typecheck inline consts separately with an inference variable as the expected return type and use the resulting type when typechecking their containing body</p>
</blockquote>
<p>where does this happen in the code?</p>
</blockquote>
<p>let me see</p>



<a name="246885220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246885220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246885220">(Jul 22 2021 at 18:12)</a>:</h4>
<p>checking this ... <a href="https://github.com/rust-lang/rust/pull/77124/commits/85b5ce264324c75eb4c67849bc42de5526ed9208">https://github.com/rust-lang/rust/pull/77124/commits/85b5ce264324c75eb4c67849bc42de5526ed9208</a></p>



<a name="246885496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246885496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246885496">(Jul 22 2021 at 18:15)</a>:</h4>
<p>let me step back a sec</p>



<a name="246885503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246885503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246885503">(Jul 22 2021 at 18:15)</a>:</h4>
<p>but yeah all it does is let's get the const using existing infrastructure and no much else</p>



<a name="246885511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246885511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246885511">(Jul 22 2021 at 18:15)</a>:</h4>
<p>inline constants, how are they represented in the HIR?</p>



<a name="246885685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246885685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246885685">(Jul 22 2021 at 18:16)</a>:</h4>
<p><code>ExprKind::ConstBlock(AnonConst)</code></p>



<a name="246885737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246885737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246885737">(Jul 22 2021 at 18:17)</a>:</h4>
<p>ok</p>



<a name="246885826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246885826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246885826">(Jul 22 2021 at 18:18)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/113bd9a349915227c880a938fa305c332cbbbcd4/compiler/rustc_typeck/src/check/expr.rs?plain=1#L290">https://github.com/rust-lang/rust/blob/113bd9a349915227c880a938fa305c332cbbbcd4/compiler/rustc_typeck/src/check/expr.rs?plain=1#L290</a></p>



<a name="246885880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246885880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246885880">(Jul 22 2021 at 18:18)</a>:</h4>
<p>I wonder how in general, not related to inline consts, how do we type check this kind of things</p>



<a name="246885894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246885894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246885894">(Jul 22 2021 at 18:18)</a>:</h4>
<p>oh, not that</p>



<a name="246885900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246885900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246885900">(Jul 22 2021 at 18:18)</a>:</h4>
<p>like even <code>let x: u32 = expr;</code></p>



<a name="246885912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246885912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246885912">(Jul 22 2021 at 18:18)</a>:</h4>
<p>how do we type check expr with the parent</p>



<a name="246885938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246885938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246885938">(Jul 22 2021 at 18:18)</a>:</h4>
<p>oh,, well, yes that</p>



<a name="246885950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246885950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246885950">(Jul 22 2021 at 18:18)</a>:</h4>
<p>ok so</p>



<a name="246886050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886050">(Jul 22 2021 at 18:19)</a>:</h4>
<p>we wind up creating an "unevaluated" constant</p>



<a name="246886122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886122">(Jul 22 2021 at 18:20)</a>:</h4>
<p>with the def-id</p>



<a name="246886159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886159">(Jul 22 2021 at 18:20)</a>:</h4>
<p>yeah</p>



<a name="246886201"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886201" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886201">(Jul 22 2021 at 18:20)</a>:</h4>
<p>I'm thinking</p>



<a name="246886232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886232">(Jul 22 2021 at 18:21)</a>:</h4>
<p>I feel like I need to "zoom out" a bit to bring enough stuff back in cache here...</p>



<a name="246886255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886255">(Jul 22 2021 at 18:21)</a>:</h4>
<p>what <span class="user-mention" data-user-id="216206">@lcnr</span> was saying earlier about closures feels right to me</p>



<a name="246886282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886282">(Jul 22 2021 at 18:21)</a>:</h4>
<p>in principle, closures are distinct functions, but we type check the surrounding function and all of its closures in one inference context</p>



<a name="246886398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886398">(Jul 22 2021 at 18:22)</a>:</h4>
<p>this is why you see code like this in the impl of various queries:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="c1">// Closures' typeck results come from their outermost function,</span>
<span class="w">    </span><span class="c1">// as they are part of the same "inference environment".</span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">outer_def_id</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">tcx</span><span class="p">.</span><span class="n">closure_base_def_id</span><span class="p">(</span><span class="n">def_id</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="n">outer_def_id</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="n">def_id</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">return</span><span class="w"> </span><span class="n">tcx</span><span class="p">.</span><span class="n">has_typeck_results</span><span class="p">(</span><span class="n">outer_def_id</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="246886438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886438">(Jul 22 2021 at 18:22)</a>:</h4>
<p>e.g., if we ask for the "typeck results" of a closure, it will redirect and instead ask for the typeck results of the closure creator</p>



<a name="246886450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886450">(Jul 22 2021 at 18:22)</a>:</h4>
<p>I see</p>



<a name="246886484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886484">(Jul 22 2021 at 18:23)</a>:</h4>
<p>makes sense</p>



<a name="246886502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886502">(Jul 22 2021 at 18:23)</a>:</h4>
<p>constants work differently</p>



<a name="246886516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886516">(Jul 22 2021 at 18:23)</a>:</h4>
<p>at least today</p>



<a name="246886669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886669">(Jul 22 2021 at 18:24)</a>:</h4>
<p>but I'm trying to put it all together in my head</p>



<a name="246886704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886704">(Jul 22 2021 at 18:24)</a>:</h4>
<p>I guess that for the purposes of typeck, the value of a const expression is irrelevant</p>



<a name="246886708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886708">(Jul 22 2021 at 18:24)</a>:</h4>
<p>we oly care about its type</p>



<a name="246886725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886725">(Jul 22 2021 at 18:25)</a>:</h4>
<p>so typeck of the const is requested and you fire a typeck of that const with it's parents, which will fire again at some point the typeck of what's inside of the const {} ?</p>



<a name="246886775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886775">(Jul 22 2021 at 18:25)</a>:</h4>
<p>that is our goal, basically</p>



<a name="246886782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886782">(Jul 22 2021 at 18:25)</a>:</h4>
<p>something like this</p>



<a name="246886835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886835">(Jul 22 2021 at 18:25)</a>:</h4>
<p>well don't remember or know that well the code to understand why this doesn't give an infinite loop :P</p>



<a name="246886895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246886895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246886895">(Jul 22 2021 at 18:26)</a>:</h4>
<p>well</p>



<a name="246887216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246887216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246887216">(Jul 22 2021 at 18:28)</a>:</h4>
<p>ok, so, we didn't get too far</p>



<a name="246887224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246887224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246887224">(Jul 22 2021 at 18:28)</a>:</h4>
<p>but that's ok</p>



<a name="246887237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246887237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246887237">(Jul 22 2021 at 18:28)</a>:</h4>
<p>the reason that it doesn't give a cycle though is this</p>



<a name="246887339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246887339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246887339">(Jul 22 2021 at 18:29)</a>:</h4>
<p>you have something like</p>
<div class="codehilite"><pre><span></span><code>Typeck(Closure) calls Typeck(Owner)
    Typeck(Owner) executes typeck_impl(owner) to create the typeck results R
    the results R contain also the results for the closure
</code></pre></div>



<a name="246887377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246887377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246887377">(Jul 22 2021 at 18:29)</a>:</h4>
<p>the point is that the <code>typeck_impl</code> never calls that query</p>



<a name="246887483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246887483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246887483">(Jul 22 2021 at 18:30)</a>:</h4>
<p>ok</p>



<a name="246887495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246887495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246887495">(Jul 22 2021 at 18:30)</a>:</h4>
<p>we'll have to talk more about it!</p>



<a name="246887570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246887570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246887570">(Jul 22 2021 at 18:31)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/260443-project-const-generics/topic/inline.20consts.20typeck/near/246886398">said</a>:</p>
<blockquote>
<p>this is why you see code like this in the impl of various queries:</p>
<p><div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="c1">// Closures' typeck results come from their outermost function,</span>
<span class="w">    </span><span class="c1">// as they are part of the same "inference environment".</span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">outer_def_id</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">tcx</span><span class="p">.</span><span class="n">closure_base_def_id</span><span class="p">(</span><span class="n">def_id</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="n">outer_def_id</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="n">def_id</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">return</span><span class="w"> </span><span class="n">tcx</span><span class="p">.</span><span class="n">has_typeck_results</span><span class="p">(</span><span class="n">outer_def_id</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</code></pre></div><br>
</p>
</blockquote>
<p>so I guess I can create a test case and try to do this <span aria-label="point up" class="emoji emoji-1f446" role="img" title="point up">:point_up:</span></p>



<a name="246887618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/inline%20consts%20typeck/near/246887618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/inline.20consts.20typeck.html#246887618">(Jul 22 2021 at 18:31)</a>:</h4>
<p>or do you see any complication or something that I may not be seeing?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>